package saxion.speelveld.spaceengineer.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class GameDB extends SQLiteOpenHelper
{

	public static final String TABLE_NAME = "game";

	public static final String COLUMN_ID = "_id";

	public static final String COLUMN_GAMEDIFFICULTY = "game_difficulty";

	public static final String COLUMN_GAMETILESINWIDTH = "game_tilesinwidth";

	public static final String COLUMN_GAMETILESINHEIGHT = "game_tilesinheight";

	public static final String COLUMN_GAMETIMETICKS = "game_timeticks";

	public static final String COLUMN_GAMEVIEWCURSORX = "game_viewcursorX";

	public static final String COLUMN_GAMEVIEWCURSORY = "game_viewcursorY";

	private static final String DATABASE_FILENAME = "game.db";

	private static int DATABASE_VERSION = 1;

	public GameDB(Context context)
	{
		super(context, DATABASE_FILENAME, null, DATABASE_VERSION);
	}

	public GameDB(Context context, String name, CursorFactory factory,
		int version)
	{
		super(context, name, factory, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db)
	{
		db.execSQL("create table " + TABLE_NAME +
			"(" + COLUMN_ID + " integer primary key autoincrement, "
			+ COLUMN_GAMEDIFFICULTY + " integer not null ,"
			+ COLUMN_GAMETILESINWIDTH + " integer not null ,"
			+ COLUMN_GAMETILESINHEIGHT + " integer not null ,"
			+ COLUMN_GAMETIMETICKS + " integer not null ,"
			+ COLUMN_GAMEVIEWCURSORX + " integer not null ,"
			+ COLUMN_GAMEVIEWCURSORY + " integer not null);");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
	{
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
		onCreate(db);
	}

}